package name.huzhenbo.java.patterns.singleton;

/**
 * Lazy initialization but unsafe.
 */
class UnsafeSingleton {
    private static UnsafeSingleton instance;
    private static int creationCount = 0;

    private UnsafeSingleton() {
    }

    public static UnsafeSingleton getInstance() {
        if (instance == null) {
            creationCount++;
            // take care of java memory model problem.
            instance = new UnsafeSingleton();
        }
        return instance;
    }

    public static int getCreationCount() {
        return creationCount;
    }
}
